/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "cat_direccion", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CatDireccion.findAll", query = "SELECT c FROM CatDireccion c"),
    @NamedQuery(name = "CatDireccion.findByDirId", query = "SELECT c FROM CatDireccion c WHERE c.dirId = :dirId"),
    @NamedQuery(name = "CatDireccion.findByDirColonia", query = "SELECT c FROM CatDireccion c WHERE c.dirColonia = :dirColonia"),
    @NamedQuery(name = "CatDireccion.findByDirCasaPol", query = "SELECT c FROM CatDireccion c WHERE c.dirCasaPol = :dirCasaPol")})
public class CatDireccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "dirId")
    private Integer dirId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "dirColonia", nullable = false, length = 20)
    private String dirColonia;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "dirCasaPol", nullable = false, length = 10)
    private String dirCasaPol;
    @JoinColumn(name = "dirUbicacionId", referencedColumnName = "Ubic_Id", nullable = false)
    @ManyToOne(optional = false)
    private Ubicacion dirUbicacionId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personaDireccionId")
    private List<Persona> personaList;

    public CatDireccion() {
    }

    public CatDireccion(Integer dirId) {
        this.dirId = dirId;
    }

    public CatDireccion(Integer dirId, String dirColonia, String dirCasaPol) {
        this.dirId = dirId;
        this.dirColonia = dirColonia;
        this.dirCasaPol = dirCasaPol;
    }

    public Integer getDirId() {
        return dirId;
    }

    public void setDirId(Integer dirId) {
        this.dirId = dirId;
    }

    public String getDirColonia() {
        return dirColonia;
    }

    public void setDirColonia(String dirColonia) {
        this.dirColonia = dirColonia;
    }

    public String getDirCasaPol() {
        return dirCasaPol;
    }

    public void setDirCasaPol(String dirCasaPol) {
        this.dirCasaPol = dirCasaPol;
    }

    public Ubicacion getDirUbicacionId() {
        return dirUbicacionId;
    }

    public void setDirUbicacionId(Ubicacion dirUbicacionId) {
        this.dirUbicacionId = dirUbicacionId;
    }

    @XmlTransient
    public List<Persona> getPersonaList() {
        return personaList;
    }

    public void setPersonaList(List<Persona> personaList) {
        this.personaList = personaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dirId != null ? dirId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CatDireccion)) {
            return false;
        }
        CatDireccion other = (CatDireccion) object;
        if ((this.dirId == null && other.dirId != null) || (this.dirId != null && !this.dirId.equals(other.dirId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.dirColonia + " " + this.dirCasaPol;
    }
    
}
